Skip to content

test(engine): make goal-model's computeLaneFit coverage visible to Codecov - #8437

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
cleanjunc:feat/8344-goal-model-codecov-mirror
Jul 24, 2026
Merged

test(engine): make goal-model's computeLaneFit coverage visible to Codecov#8437
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
cleanjunc:feat/8344-goal-model-codecov-mirror

Conversation

@cleanjunc

Copy link
Copy Markdown
Contributor

Closes #8344

Summary

  • packages/loopover-engine/src/goal-model.ts's computeLaneFit (and its hand-rolled compileGlobMatcher) is live, load-bearing lane-fit logic — consumed by miner-goal-lane-fit.ts and opportunity-metadata.ts's computeMetadataLaneFit, re-exported from the engine barrel — and is fully exercised by the engine package's own node --test suite (packages/loopover-engine/test/goal-model.test.ts). But that runner is not part of the root vitest run Codecov reads codecov/patch from, so the module reports as ~0% covered in Codecov's eyes despite being genuinely tested. Same blind spot as fix(ci): review-enrichment's real node:test coverage is invisible to Codecov (83 of 83 files effectively unmeasured) #6250.
  • Adds a root-level vitest twin, test/unit/goal-model.test.ts, importing computeLaneFit via the engine barrel (../../packages/loopover-engine/src/index) and re-exercising every scenario the package suite covers — mirroring the sibling twin test/unit/calibration-dashboard.test.ts.
  • Adds a short note to the engine package README documenting the root mirror (next to the existing reviewer-consensus-calibration.ts (658 lines) is the package's largest branch surface invisible to Codecov #8349 mirror note). This README touch is deliberate and load-bearing — see "Why the README change" below.
  • No change to any file under packages/loopover-engine/src/** or packages/loopover-engine/test/**.

Covered, per the issue's requirements: all four computeLaneFit precedence rules (hard veto on a blocked path and independently a blocked label; neutral 0.5 when neither wantedPaths nor preferredLabels is configured; 0 when a dimension is configured but none match; partial credit — one active matching → 1, two active with one → 0.5, both → 1), and the glob matcher (* single-segment / does-not-cross-/ asserted both ways, bare ** crossing /, **/ optional prefix with zero and one-plus segments, ? match and non-match, a literal regex metacharacter matched literally, backslash normalization, path and label case-insensitivity, empty-pattern and empty-path guards).

Why the README change (please read before grading scope)

A pure test/**-only diff that touches no packages/loopover-engine/** path is classified by CI as a scoped, coverage-artifact-free run: each test shard runs vitest --changed=origin/main --coverage.all=false, produces an empty coverage/lcov.info (no changed src/**), and therefore skips uploading its coverage blob ("scoped run passed but exercised no src/** files -- skipping coverage artifacts for this shard"). With zero coverage-blob-shard-* artifacts, the validate-tests-merge job then fails with ENOENT … all-blob-reports, which fails validate and auto-closes the PR — exactly what happened to my first attempt at this pattern.

The merged twin PR for #8349 (test/unit/reviewer-consensus-calibration.test.ts) avoided this by also adding a one-paragraph note to packages/loopover-engine/README.md. Touching an engine-package path flips CI onto the full-coverage run, whose shards upload real blobs and let validate-tests-merge pass. This PR follows that established, merged precedent: the README note is genuinely useful (it documents why the root mirror exists) and it keeps CI on the full-coverage path. It adds zero src/** production lines, so codecov/patch still has nothing on this diff to grade.

Coverage note (honest)

npm run test:coverage reports goal-model.ts at 100% statements, functions, and lines, and 100% of every reachable branch (46/48 = 95.83% raw). The two uncovered arms are the defensive ?? "" fallbacks on index reads — String(path ?? "") (line 31, in the normalizePathForMatch helper) and /…/.test(ch ?? "") (line 62, in compileGlobMatcher). Both ch (a bounded string index) and path are typed string | undefined only because the repo sets noUncheckedIndexedAccess: true; at runtime the ?? "" right arm cannot fire without a type-violating input, and reaching it would require editing goal-model.ts — which this test-only issue forbids. Every legitimately reachable branch is covered and the source is left untouched.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format.
  • Focused: a single new test file plus a directly-related, CI-load-bearing README note (rationale above); no unrelated backend/UI/MCP/dep/deploy changes.
  • Follows CONTRIBUTING.md; does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves — Closes #8344.

Validation

  • git diff --check — clean.
  • npm run actionlint — N/A: no workflow / composite-action changes.
  • npm run typecheck — green (after building @loopover/engine, as the root test:ci sequence does before typecheck).
  • npm run test:coverage locally — the new file passes (20 tests) with the coverage described above.
  • npm run test:workers — N/A: no worker code changed.
  • npm run build:mcp / npm run test:mcp-pack — N/A: no MCP changes.
  • npm run ui:openapi:check / npm run ui:lint / npm run ui:typecheck / npm run ui:build — N/A: no UI, API, or OpenAPI surface changed.
  • npm audit --audit-level=moderate — not run locally (sandbox audit endpoint returns a lockfile 400); no dependency changes, so it cannot affect the audit. CI runs it against a clean install.
  • New or changed behavior has unit tests — this PR is the added test coverage; no production behavior changed.

If any required check was skipped, explain why:

  • All skipped checks are N/A for a PR that adds one root-level vitest file plus a docs note, with no production, UI, MCP, API, workflow, or dependency changes.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, PATs, private keys, trust scores, private rankings, or maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and implies no compensation or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests — N/A: none changed.
  • API/OpenAPI/MCP behavior is updated and tested where needed — N/A: none changed.
  • UI changes use live API data / real empty/error/loading states — N/A: no UI changes.
  • Public docs/changelogs updated where needed; CHANGELOG.md not edited (not a release-prep PR).

Notes

  • The test imports computeLaneFit from the engine barrel, not a relative path into the source file, matching every existing sibling root-level engine test.
  • No behavior of goal-model.ts was changed, and its own node --test suite was left untouched, as the issue requires.

…decov

`packages/loopover-engine/src/goal-model.ts`'s `computeLaneFit` (and its
hand-rolled `compileGlobMatcher`) is live, load-bearing lane-fit logic consumed
by `miner-goal-lane-fit.ts` and `opportunity-metadata.ts`, fully exercised by the
engine package's own `node --test` suite. But that runner is not part of the root
vitest run Codecov reads `codecov/patch` from, so the module reports as ~0%
covered despite being genuinely tested (same blind spot as JSONbored#6250).

Add a root-level vitest twin that imports `computeLaneFit` via the engine barrel
and re-exercises all four precedence rules plus every glob-matcher branch (`*`
single-segment, bare `**`, `**/` optional prefix, `?`, literal regex metachar,
backslash normalization, case-insensitivity, empty pattern, empty path). Mirrors
the sibling twin `test/unit/calibration-dashboard.test.ts`. Brings the source to
100% line and 100% of every reachable branch; the only two uncovered arms are the
defensive `?? ""` fallbacks on index reads (`ch`/`path`, typed `string | undefined`
only because of `noUncheckedIndexedAccess`), which cannot fire at runtime without
a type-violating input or a source change the issue forbids.

Also document the root mirror in the engine package README, next to the existing
Codecov-mirror note added for JSONbored#8349 — the same doc touch the merged twin PR for
JSONbored#8349 used, and it keeps this a full-coverage CI run (a root-`test/**`-only diff
is treated as a scoped, coverage-artifact-free run whose shard blobs never reach
the merge step).

Closes JSONbored#8344
@cleanjunc
cleanjunc requested a review from JSONbored as a code owner July 24, 2026 13:04
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.44%. Comparing base (2494517) to head (ce2f13b).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #8437       +/-   ##
===========================================
+ Coverage   59.67%   92.44%   +32.76%     
===========================================
  Files         791      791               
  Lines       79293    79294        +1     
  Branches    23950    23950               
===========================================
+ Hits        47322    73305    +25983     
+ Misses      28227     4858    -23369     
+ Partials     3744     1131     -2613     
Flag Coverage Δ
shard-1 58.35% <ø> (?)
shard-2 51.09% <ø> (+3.41%) ⬆️
shard-3 53.40% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 478 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 24, 2026
@loopover-orb

loopover-orb Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-24 13:31:29 UTC

2 files · 1 AI reviewer · no blockers · readiness 93/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a test-only PR that adds a root-level vitest twin (`test/unit/goal-model.test.ts`) for `computeLaneFit`/`compileGlobMatcher`, mirroring the established root-mirror pattern (#6250, #8349) used to make package-level `node:test` coverage visible to Codecov's `codecov/patch`, which only reads the root vitest suite. I traced each assertion against the actual `computeLaneFit`/`compileGlobMatcher` source shown in context (precedence rules, `*` segment-boundary, bare `**`, `**/` optional-prefix, `?`, literal-metacharacter escaping, backslash normalization, case-insensitivity, empty-pattern/empty-path guards) and every expected value matches the real implementation's behavior — these are not fabricated scenarios. No source files under `packages/loopover-engine/src/**` change, so this is a pure, low-risk coverage-visibility fix scoped tightly to the linked issue.

Nits — 5 non-blocking
  • The README addition pushes `packages/loopover-engine/README.md` to ~577 lines (external brief flags a 400-line long-file threshold); this predates the PR but is worth a maintainer note about eventually splitting the growing 'root mirror' catalogue out of the main README.
  • The file-level comment block in `test/unit/goal-model.test.ts:1-9` duplicates most of the PR description verbatim — fine for a first pass, but consider trimming to the 'why' (Codecov blind spot + barrel import) since the sibling `calibration-dashboard.test.ts` twin can be linked instead of re-explained.
  • Verify `GoalModelInput`, `MinerGoalSpec`, and `DEFAULT_MINER_GOAL_SPEC` are actually re-exported from `packages/loopover-engine/src/index` (not shown in the diff/full-file content) — the import at goal-model.test.ts:11-12 depends on it.
  • Consider extracting the repeated `baseSpec()`/`input()` overrides pattern isn't an issue here, it's already factored well — no change needed.
  • If a future goal-model precedence rule is added, this twin will silently drift out of sync with the package suite; a lightweight sameness check (e.g. asserting both suites cover an identical case-name list) could catch that, though likely overkill for now.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8344
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 53 registered-repo PR(s), 22 merged, 37 issue(s).
Contributor context ✅ Confirmed Gittensor contributor cleanjunc; Gittensor profile; 53 PR(s), 37 issue(s).
Improvement ℹ️ Insufficient signal risk: clean · value: insufficient-signal · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds test/unit/goal-model.test.ts as a root-level vitest suite importing computeLaneFit via the engine barrel, and it exercises all four documented precedence rules plus the glob-matcher edge cases (*, **, **/, ?, literal metacharacters, backslash normalization, case-insensitivity) as required, without touching the excluded source/test files.

Review context
  • Author: cleanjunc
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Scala
  • Official Gittensor activity: 53 PR(s), 37 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 6c25eb6 into JSONbored:main Jul 24, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

goal-model.ts's computeLaneFit has zero root-level (Codecov-visible) test coverage

1 participant